<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>事件的冒泡</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        /*.box1{
            width: 200px;
            height: 200px;
            background-color: red;
            position: relative;
        }

        .box2 {
            width: 100px;
            height: 100px;
            background-color: green;
            position: absolute;
            top: 50px;
            left: 50px;

        }*/
        .box1 {
            width: 200px;
            height: 200px;
            background-color: red;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .box2 {
            width: 100px;
            height: 100px;
            background-color: green;
        }
    </style>
</head>
<body>
<div id="change" class="change">
    <div class="box1">
        <div class="box2"></div>
    </div>
</div>

<script>
    let outer = document.querySelector("#change .box1");
    let inner = document.querySelector("#change .box2");


    outer.addEventListener("click", function () {
        console.log("点击了外部区域");
    })

    inner.addEventListener("click", function () {
        console.log("点击了内部区域");
    })
</script>
</body>
</html>